package com.pig4cloud.pig.admin.emqx.interceptor;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import okhttp3.Credentials;
import org.springframework.beans.factory.annotation.Value;

/**
 * @author lh
 */
public class EmqxFeignClientInterceptor  implements RequestInterceptor {

	@Value("${emqx.apiKey}")
	private String username;
	@Value("${emqx.secretKey}")
	private String password;
	@Override
	public void apply(RequestTemplate requestTemplate) {
		requestTemplate.header("Content-Type", "application/json");
		requestTemplate.header("Authorization", Credentials.basic(username, password));
	}
}
